package com.anjoyo.xgh.musicshare.util;

import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;

public class StringUtil {

	// 使用系统当前日期加以调整作为照片的名称
	public static String getPhotoFileName() {
		Date date = new Date(System.currentTimeMillis());
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"'IMG'_yyyyMMdd_HHmmss");
		return dateFormat.format(date) + ".jpg";
	}

	public static String pasekongge(String url) {
		String urls = url;
		try {
			urls = url.replaceAll("\\s", "%20");
		} catch (Exception e) {
			System.out.println("urls错误");
		}
		return urls;
	}

	// 转码
	public static String zhuanma(String url) {
		String urls = null;
		try {
			urls = URLEncoder.encode(url);
			url = urls.replaceAll("\\+", "%20");
		} catch (Exception e) {
			System.out.println("转码错误");
		}
		return url;
	}

	public static String dateChange(String str) {
		Date date = new Date(Long.valueOf(str));
		SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日  HH:mm:ss");
		String time = format.format(date);
		return time;
	}

	public static boolean isnull(String string) {
		if (string == null || string.equals("")) {
			return true;
		} else {
			return false;
		}
	}

	public static String turnTime(int time) {
		int min = time / 60000;
		int sec = time % 60000 / 1000;
		String m = "";
		String s = "";
		if (min<10) {
			m ="0"+min;
		}else {
			m = ""+min;
		}
		if (sec<10) {
			s ="0"+sec;
		}else {
			s = ""+sec;
		}
		return m+":"+s;
	}
}
